package sim;

import javax.swing.SwingUtilities;

public class DiscreteTimeCounter{
	
	int customerCount;
	long arrivalTimeSum;
	long serviceInitiationTimeSum;
	long serviceCompletionTimeSum;
	
	private DiscreteHistogramm histogramm;
	
	public DiscreteTimeCounter() {
		histogramm = new DiscreteHistogramm();
		customerCount = 0;
		arrivalTimeSum = 0;
		serviceInitiationTimeSum = 0;
		serviceCompletionTimeSum = 0;
	}
	
	public void graspCustomer(Customer c) {
		customerCount++;
		long arrivalTime = c.getArrivalTime();
		long serviceIniationTime = c.getServiceInitiationTime();
		long serviceCompletionTime = c.getServiceCompletionTime();
		arrivalTimeSum += arrivalTime;
		serviceInitiationTimeSum += serviceIniationTime;
		serviceCompletionTimeSum += serviceCompletionTime;
//		histogramm.pushValues(c);
	}


	public void report() {
		arrivalTimeSum /= customerCount;
		serviceInitiationTimeSum /= customerCount;
		serviceCompletionTimeSum /= customerCount;
		System.out.println("Erwartungswert: " + 
				"Arrival Time: " + arrivalTimeSum + "\n" + 
				"Service Initiation Time: " + serviceInitiationTimeSum + "\n" + 
				"Service Completion Time: " + serviceCompletionTimeSum
				);
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
//				histogramm.run();
			}
		});
	}

}
